/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Models;

import EntitiesTier.ClEmpresa;
import java.util.Arrays;
import java.util.List;
import javax.swing.table.AbstractTableModel;

/**
 *
 * @author Douglas
 */
public class EmpresaTableModel extends AbstractTableModel{
    
    private List<ClEmpresa> emp;
    private List<String> colunas;

    
    public EmpresaTableModel(List<ClEmpresa> emp) throws Exception
    {
       this.emp = emp;
       colunas = Arrays.asList("Cod.",  "Nome",  "Razão",  "CNPJ",  "IE",  "Endereço",  "Num",  
         "Bairro",  "Cidade", "UF",  "CEP",  "Tel.", "Email");
    }
    
    @Override
    public int getRowCount() {
        return emp.size();
    }

    @Override
    public int getColumnCount() {
        return 13;
    }

    @Override
    public Object getValueAt(int lin, int col) {
        ClEmpresa cle = emp.get(lin);
        switch(col)
        {
            case 0 : return cle.getEMP_COD();
            case 1 : return cle.getEMP_NOME();
            case 2 : return cle.getEMP_RAZAO();
            case 3 : return cle.getEMP_CNPJ();
            case 4 : return cle.getEMP_IE();
            case 5 : return cle.getEMP_ENDERECO();
            case 6 : return cle.getEMP_NUM();
            case 7 : return cle.getEMP_BAIRRO();
            case 8 : return cle.getEMP_CIDADE();
            case 9 : return cle.getEMP_UF();
            case 10 : return cle.getEMP_CEP();
            case 11 : return cle.getEMP_FONE1();
            case 12 : return cle.getEMP_EMAIL();
            default : return "";
        }
    }

    @Override
    public String getColumnName(int col) {
        return colunas.get(col);
    }
    
    
    
}
